package com.ds.components.composite;

import com.ds.components.bars.ElbowBar;
import com.ds.components.grid.AbstractDisplayGrid;
import com.ds.components.grid.DisplayGrid;

import javax.swing.*;
import java.awt.*;

public class DisplayGridBar extends ComponentBar
{
	public AbstractDisplayGrid grid;

	public DisplayGridBar()
	{
		this.grid = new DisplayGrid();
	}

	public JComponent getMainContainer()
	{
		super.getMainContainer();

		JPanel p = new JPanel();
		p.setBackground( Color.black );
		if( this.topElbowBar.getConnectorPosition() == ElbowBar.LEFT_CONNECTOR )
		{
			p.setLayout( new FlowLayout( FlowLayout.LEFT, 2, 2 ) );
		}
		else
		{
			p.setLayout( new FlowLayout( FlowLayout.RIGHT, 2, 2 ) );
		}
		
		Dimension d = grid.getPreferredSize();

		p.setPreferredSize( new Dimension( (int)d.getWidth() + 25, (int)d.getHeight() ) );
		p.add( grid );

		this.contents.add( p, BorderLayout.CENTER );

		return this.contents;
	}
}
